<?php

namespace Managers;

class View extends \Lib\Model\DoctrineManager{

    public function getAllTypes() {
        
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder()
                ->select('t')
                ->from('Entities\MessageType', 't');
        
        $result = $qb->getQuery()->getResult();
        
        return $result;
        
    }
    
    
    public function getContentByType($type, $id) {
        $entity ='Entities'.'\\'.\ucfirst($type);
        
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder()
                ->select('e')
                ->from($entity, 'e')
                ->where('e.'.$type.'Id = :id')
                ->setParameter('id', $id);
        
        

        
        $result = $qb->getQuery()->getSingleResult();
        
        
        return $result;
        
    }
    
}